import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);

/**
 * 创建 store 函数
 * @param {object} obj
 * @param {object} obj.state     - 页面的 state
 * @param {object} obj.getters   - 页面的 getter
 * @param {object} obj.mutations - 页面的 mutaions
 * @param {object} obj.action    - 页面的 actions
 * @param {object} obj.modules   - 页面的 modules
 */

export default  ({state, getters, mutations, actions,modules})=> {
  return new Vuex.Store({
    state: {
      ...state,
      loadingStatus:false
    },
    getters: {
      ...getters,
      loadingStatus (state) {
        return state.loadingStatus
      }
    },
    mutations: {
      ...mutations,
      setLoadingStatus (state, payload) {
        state.loadingStatus = payload
      }
    },
    actions: {
      ...actions
    },
    modules: {
      ...modules
    },
    strict: true,
    namespaced: true
  });
}
